<html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - matrix.h</title></head><body bgcolor='white'><pre>
<font color='#009900'>// Copyright (C) 2006  Davis E. King (davis@dlib.net)
</font><font color='#009900'>// License: Boost Software License   See LICENSE.txt for the full license.
</font><font color='#0000FF'>#ifndef</font> DLIB_MATRIx_
<font color='#0000FF'>#define</font> DLIB_MATRIx_

<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='matrix_exp.h.html'>matrix_exp.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='matrix_abstract.h.html'>matrix_abstract.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../algs.h.html'>../algs.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../serialize.h.html'>../serialize.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../enable_if.h.html'>../enable_if.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>sstream<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>algorithm<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../memory_manager.h.html'>../memory_manager.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='../is_kind.h.html'>../is_kind.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='matrix_data_layout.h.html'>matrix_data_layout.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='matrix_assign_fwd.h.html'>matrix_assign_fwd.h</a>"
<font color='#0000FF'>#include</font> "<a style='text-decoration:none' href='matrix_op.h.html'>matrix_op.h</a>"
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>utility<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#ifdef</font> DLIB_HAS_INITIALIZER_LISTS
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>initializer_list<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#endif</font>

<font color='#0000FF'>#ifdef</font> MATLAB_MEX_FILE
<font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>mex.h<font color='#5555FF'>&gt;</font>
<font color='#0000FF'>#endif</font>

<font color='#0000FF'>#ifdef</font> _MSC_VER
<font color='#0000FF'>#pragma</font> warning<font face='Lucida Console'>(</font>push<font face='Lucida Console'>)</font>

<font color='#009900'>// Disable the following warnings for Visual Studio
</font>
<font color='#009900'>// This warning is:
</font><font color='#009900'>//    "warning C4355: 'this' : used in base member initializer list"
</font><font color='#009900'>// Which we get from this code but it is not an error so I'm turning this
</font><font color='#009900'>// warning off and then turning it back on at the end of the file.
</font><font color='#0000FF'>#pragma</font> warning<font face='Lucida Console'>(</font>disable : <font color='#979000'>4355</font><font face='Lucida Console'>)</font>

<font color='#009900'>// "warning C4723: potential divide by 0" - This warning is triggered in
</font><font color='#009900'>// matrix(const std::initializer_list&lt;T&gt;&amp; l) where the compiler can see that
</font><font color='#009900'>// matrix&lt;&gt; was templated in a way making NR ending up 0, but division by 0 at runtime
</font><font color='#009900'>// is not possible because the division operation is inside "if (NR!=0)" block.
</font><font color='#0000FF'>#pragma</font> warning<font face='Lucida Console'>(</font>disable : <font color='#979000'>4723</font><font face='Lucida Console'>)</font>

<font color='#009900'>// "warning C4724: potential mod by 0" - This warning is triggered in
</font><font color='#009900'>// matrix(const std::initializer_list&lt;T&gt;&amp; l) where the compiler can see that
</font><font color='#009900'>// matrix&lt;&gt; was templated in a way making NR ending up 0, but mod by 0 at runtime
</font><font color='#009900'>// is not possible because the mod operation is inside "if (NR!=0)" block.
</font><font color='#0000FF'>#pragma</font> warning<font face='Lucida Console'>(</font>disable : <font color='#979000'>4724</font><font face='Lucida Console'>)</font>

<font color='#0000FF'>#endif</font>

<font color='#0000FF'>namespace</font> dlib
<b>{</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#009900'>// This template will perform the needed loop for element multiplication using whichever
</font>    <font color='#009900'>// dimension is provided as a compile time constant (if one is at all).
</font>    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> LHS,
        <font color='#0000FF'>typename</font> RHS,
        <font color='#0000FF'><u>long</u></font> lhs_nc <font color='#5555FF'>=</font> LHS::NC,
        <font color='#0000FF'><u>long</u></font> rhs_nr <font color='#5555FF'>=</font> RHS::NR
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_multiply_helper'></a>matrix_multiply_helper</b> 
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type type;
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> RHS_, <font color='#0000FF'>typename</font> LHS_<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> type  <b><a name='eval'></a>eval</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> RHS_<font color='#5555FF'>&amp;</font> rhs,
            <font color='#0000FF'>const</font> LHS_<font color='#5555FF'>&amp;</font> lhs,
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font>  
        <b>{</b> 
            type temp <font color='#5555FF'>=</font> <font color='#BB00BB'>lhs</font><font face='Lucida Console'>(</font>r,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>rhs</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,c<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>1</font>; i <font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <b>{</b>
                temp <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>lhs</font><font face='Lucida Console'>(</font>r,i<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>rhs</font><font face='Lucida Console'>(</font>i,c<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> temp;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> LHS,
        <font color='#0000FF'>typename</font> RHS,
        <font color='#0000FF'><u>long</u></font> lhs_nc 
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_multiply_helper'></a>matrix_multiply_helper</b> <font color='#5555FF'>&lt;</font>LHS,RHS,lhs_nc,<font color='#979000'>0</font><font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type type;
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> RHS_, <font color='#0000FF'>typename</font> LHS_<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> type  <b><a name='eval'></a>eval</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> RHS_<font color='#5555FF'>&amp;</font> rhs,
            <font color='#0000FF'>const</font> LHS_<font color='#5555FF'>&amp;</font> lhs,
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font>  
        <b>{</b> 
            type temp <font color='#5555FF'>=</font> <font color='#BB00BB'>lhs</font><font face='Lucida Console'>(</font>r,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>rhs</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,c<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>1</font>; i <font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
            <b>{</b>
                temp <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font color='#BB00BB'>lhs</font><font face='Lucida Console'>(</font>r,i<font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font color='#BB00BB'>rhs</font><font face='Lucida Console'>(</font>i,c<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> temp;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS, <font color='#0000FF'>typename</font> RHS<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_multiply_exp'></a>matrix_multiply_exp</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS, <font color='#0000FF'>typename</font> RHS<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> LHS::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> RHS::NC;

<font color='#0000FF'>#ifdef</font> DLIB_USE_BLAS
        <font color='#009900'>// if there are BLAS functions to be called then we want to make sure we
</font>        <font color='#009900'>// always evaluate any complex expressions so that the BLAS bindings can happen.
</font>        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> lhs_is_costly <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>LHS::cost <font color='#5555FF'>&gt;</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font><font face='Lucida Console'>(</font>RHS::NC <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> LHS::cost <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>10000</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> rhs_is_costly <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>RHS::cost <font color='#5555FF'>&gt;</font> <font color='#979000'>2</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font><font face='Lucida Console'>(</font>LHS::NR <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> RHS::cost <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>10000</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>#else</font>
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> lhs_is_costly <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>LHS::cost <font color='#5555FF'>&gt;</font> <font color='#979000'>4</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font><font face='Lucida Console'>(</font>RHS::NC <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> rhs_is_costly <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>RHS::cost <font color='#5555FF'>&gt;</font> <font color='#979000'>4</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font><font face='Lucida Console'>(</font>LHS::NR <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>;
<font color='#0000FF'>#endif</font>

        <font color='#009900'>// Note that if we decide that one of the matrices is too costly we will evaluate it
</font>        <font color='#009900'>// into a temporary.  Doing this resets its cost back to 1.
</font>        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> lhs_cost <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>lhs_is_costly<font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>true</font><font face='Lucida Console'>)</font>? <font color='#979000'>1</font> : <font face='Lucida Console'>(</font>LHS::cost<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> rhs_cost <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>rhs_is_costly<font color='#5555FF'>=</font><font color='#5555FF'>=</font><font color='#979000'>true</font><font face='Lucida Console'>)</font>? <font color='#979000'>1</font> : <font face='Lucida Console'>(</font>RHS::cost<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

        <font color='#009900'>// The cost of evaluating an element of a matrix multiply is the cost of evaluating elements from
</font>        <font color='#009900'>// RHS and LHS times the number of rows/columns in the RHS/LHS matrix.  If we don't know the matrix
</font>        <font color='#009900'>// dimensions then just assume it is really large.
</font>        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>tmax<font color='#5555FF'>&lt;</font>LHS::NC,RHS::NR<font color='#5555FF'>&gt;</font>::value<font color='#5555FF'>!</font><font color='#5555FF'>=</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>? <font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>lhs_cost<font color='#5555FF'>+</font>rhs_cost<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>tmax<font color='#5555FF'>&lt;</font>LHS::NC,RHS::NR<font color='#5555FF'>&gt;</font>::value<font face='Lucida Console'>)</font>:<font face='Lucida Console'>(</font><font color='#979000'>10000</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'><u>bool</u></font> is_ref<font color='#5555FF'>&gt;</font> <font color='#0000FF'>struct</font> <b><a name='conditional_matrix_temp'></a>conditional_matrix_temp</b> <b>{</b> <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> T::matrix_type type; <b>}</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font> <font color='#0000FF'>struct</font> <b><a name='conditional_matrix_temp'></a>conditional_matrix_temp</b><font color='#5555FF'>&lt;</font>T,<font color='#979000'>true</font><font color='#5555FF'>&gt;</font>      <b>{</b> <font color='#0000FF'>typedef</font> T<font color='#5555FF'>&amp;</font> type; <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> LHS,
        <font color='#0000FF'>typename</font> RHS
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_multiply_exp'></a>matrix_multiply_exp</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#009900'>/*!
            REQUIREMENTS ON LHS AND RHS
                - must be matrix_exp objects.
        !*/</font>
    <font color='#0000FF'>public</font>:

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::cost;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::layout_type layout_type;


        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> lhs_is_costly <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::lhs_is_costly;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> rhs_is_costly <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::rhs_is_costly;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> either_is_costly <font color='#5555FF'>=</font> lhs_is_costly <font color='#5555FF'>|</font><font color='#5555FF'>|</font> rhs_is_costly;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>bool</u></font> both_are_costly <font color='#5555FF'>=</font> lhs_is_costly <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> rhs_is_costly;

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> conditional_matrix_temp<font color='#5555FF'>&lt;</font><font color='#0000FF'>const</font> LHS,lhs_is_costly <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font color='#5555FF'>&gt;</font>::type LHS_ref_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> conditional_matrix_temp<font color='#5555FF'>&lt;</font><font color='#0000FF'>const</font> RHS,rhs_is_costly <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font color='#5555FF'>&gt;</font>::type RHS_ref_type;

        <font color='#009900'>// This constructor exists simply for the purpose of causing a compile time error if
</font>        <font color='#009900'>// someone tries to create an instance of this object with the wrong kind of objects.
</font>        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T1, <font color='#0000FF'>typename</font> T2<font color='#5555FF'>&gt;</font>
        <b><a name='matrix_multiply_exp'></a>matrix_multiply_exp</b> <font face='Lucida Console'>(</font>T1,T2<font face='Lucida Console'>)</font>; 

        <font color='#0000FF'>inline</font> <b><a name='matrix_multiply_exp'></a>matrix_multiply_exp</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> LHS<font color='#5555FF'>&amp;</font> lhs_,
            <font color='#0000FF'>const</font> RHS<font color='#5555FF'>&amp;</font> rhs_
        <font face='Lucida Console'>)</font> :
            lhs<font face='Lucida Console'>(</font>lhs_<font face='Lucida Console'>)</font>,
            rhs<font face='Lucida Console'>(</font>rhs_<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// You are trying to multiply two incompatible matrices together.  The number of columns 
</font>            <font color='#009900'>// in the matrix on the left must match the number of rows in the matrix on the right.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>LHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> RHS::NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> LHS::NC<font color='#5555FF'>*</font>RHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> lhs.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> rhs.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tconst matrix_exp operator*(const matrix_exp&amp; lhs, const matrix_exp&amp; rhs)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou are trying to multiply two incompatible matrices together</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlhs.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlhs.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trhs.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trhs.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t&amp;lhs: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#5555FF'>&amp;</font>lhs 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t&amp;rhs: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#5555FF'>&amp;</font>rhs 
                <font face='Lucida Console'>)</font>;

            <font color='#009900'>// You can't multiply matrices together if they don't both contain the same type of elements.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS::type, <font color='#0000FF'>typename</font> RHS::type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> 
            <font color='#0000FF'>return</font> matrix_multiply_helper<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font>::<font color='#BB00BB'>eval</font><font face='Lucida Console'>(</font>rhs,lhs,r,c<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>long</u></font> i <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> <font color='#0000FF'>return</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&gt;</font>::<font color='#0000FF'>operator</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> rhs.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        LHS_ref_type lhs;
        RHS_ref_type rhs;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font> <font color='#0000FF'>typename</font> EXP1, <font color='#0000FF'>typename</font> EXP2 <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m1.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, m2.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M, <font color='#0000FF'><u>bool</u></font> use_reference <font color='#5555FF'>=</font> <font color='#979000'>true</font><font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_mul_scal_exp'></a>matrix_mul_scal_exp</b>;

    <font color='#009900'>// -------------------------
</font>
    <font color='#009900'>// Now we declare some overloads that cause any scalar multiplications to percolate 
</font>    <font color='#009900'>// up and outside of any matrix multiplies.  Note that we are using the non-reference containing
</font>    <font color='#009900'>// mode of the matrix_mul_scal_exp object since we are passing in locally constructed matrix_multiply_exp 
</font>    <font color='#009900'>// objects.  So the matrix_mul_scal_exp object will contain copies of matrix_multiply_exp objects
</font>    <font color='#009900'>// rather than references to them.  This could result in extra matrix copies if the matrix_multiply_exp
</font>    <font color='#009900'>// decided it should evaluate any of its arguments.  So we also try to not apply this percolating operation 
</font>    <font color='#009900'>// if the matrix_multiply_exp would contain a fully evaluated copy of the original matrix_mul_scal_exp 
</font>    <font color='#009900'>// expression.
</font>    <font color='#009900'>// 
</font>    <font color='#009900'>// Also, the reason we want to apply this transformation in the first place is because it (1) makes
</font>    <font color='#009900'>// the expressions going into matrix multiply expressions simpler and (2) it makes it a lot more
</font>    <font color='#009900'>// straightforward to bind BLAS calls to matrix expressions involving scalar multiplies.
</font>    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font> <font color='#0000FF'>typename</font> EXP1, <font color='#0000FF'>typename</font> EXP2 <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if_c<font color='#5555FF'>&lt;</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font>, matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::both_are_costly ,      
                                        matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font>,<font color='#979000'>false</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font> exp1;
        <font color='#0000FF'>typedef</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>exp1,<font color='#979000'>false</font><font color='#5555FF'>&gt;</font> exp2;
        <font color='#0000FF'>return</font> <font color='#BB00BB'>exp2</font><font face='Lucida Console'>(</font><font color='#BB00BB'>exp1</font><font face='Lucida Console'>(</font>m1.m, m2.m<font face='Lucida Console'>)</font>, m1.s<font color='#5555FF'>*</font>m2.s<font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font> <font color='#0000FF'>typename</font> EXP1, <font color='#0000FF'>typename</font> EXP2 <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if_c<font color='#5555FF'>&lt;</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font>, EXP2 <font color='#5555FF'>&gt;</font>::lhs_is_costly ,      
                                      matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font>,<font color='#979000'>false</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font> exp1;
        <font color='#0000FF'>typedef</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>exp1,<font color='#979000'>false</font><font color='#5555FF'>&gt;</font> exp2;
        <font color='#0000FF'>return</font> <font color='#BB00BB'>exp2</font><font face='Lucida Console'>(</font><font color='#BB00BB'>exp1</font><font face='Lucida Console'>(</font>m1.m, m2.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, m1.s<font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font> <font color='#0000FF'>typename</font> EXP1, <font color='#0000FF'>typename</font> EXP2 <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if_c<font color='#5555FF'>&lt;</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::rhs_is_costly ,      
                                      matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font>,<font color='#979000'>false</font><font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> matrix_multiply_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font> exp1;
        <font color='#0000FF'>typedef</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>exp1,<font color='#979000'>false</font><font color='#5555FF'>&gt;</font> exp2;
        <font color='#0000FF'>return</font> <font color='#BB00BB'>exp2</font><font face='Lucida Console'>(</font><font color='#BB00BB'>exp1</font><font face='Lucida Console'>(</font>m1.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, m2.m<font face='Lucida Console'>)</font>, m2.s<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS, <font color='#0000FF'>typename</font> RHS<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_add_exp'></a>matrix_add_exp</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS, <font color='#0000FF'>typename</font> RHS<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>RHS::NR <font color='#5555FF'>&gt;</font> LHS::NR<font face='Lucida Console'>)</font> ? RHS::NR : LHS::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>RHS::NC <font color='#5555FF'>&gt;</font> LHS::NC<font face='Lucida Console'>)</font> ? RHS::NC : LHS::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> LHS::cost<font color='#5555FF'>+</font>RHS::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> LHS,
        <font color='#0000FF'>typename</font> RHS
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_add_exp'></a>matrix_add_exp</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#009900'>/*!
            REQUIREMENTS ON LHS AND RHS
                - must be matrix_exp objects. 
        !*/</font>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::cost;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::layout_type layout_type;

        <font color='#009900'>// This constructor exists simply for the purpose of causing a compile time error if
</font>        <font color='#009900'>// someone tries to create an instance of this object with the wrong kind of objects.
</font>        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T1, <font color='#0000FF'>typename</font> T2<font color='#5555FF'>&gt;</font>
        <b><a name='matrix_add_exp'></a>matrix_add_exp</b> <font face='Lucida Console'>(</font>T1,T2<font face='Lucida Console'>)</font>; 

        <b><a name='matrix_add_exp'></a>matrix_add_exp</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> LHS<font color='#5555FF'>&amp;</font> lhs_,
            <font color='#0000FF'>const</font> RHS<font color='#5555FF'>&amp;</font> rhs_
        <font face='Lucida Console'>)</font> :
            lhs<font face='Lucida Console'>(</font>lhs_<font face='Lucida Console'>)</font>,
            rhs<font face='Lucida Console'>(</font>rhs_<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// You can only add matrices together if they both have the same number of rows and columns.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>LHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> RHS::NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> LHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> RHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>LHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> RHS::NC <font color='#5555FF'>|</font><font color='#5555FF'>|</font> LHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> RHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                   lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, 
                "<font color='#CC0000'>\tconst matrix_exp operator+(const matrix_exp&amp; lhs, const matrix_exp&amp; rhs)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou are trying to add two incompatible matrices together</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlhs.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlhs.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trhs.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trhs.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t&amp;lhs: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#5555FF'>&amp;</font>lhs 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t&amp;rhs: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#5555FF'>&amp;</font>rhs 
                <font face='Lucida Console'>)</font>;

            <font color='#009900'>// You can only add matrices together if they both contain the same types of elements.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS::type, <font color='#0000FF'>typename</font> RHS::type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>lhs</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> <font color='#BB00BB'>rhs</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>long</u></font> i <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> <font color='#0000FF'>return</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_add_exp<font color='#5555FF'>&gt;</font>::<font color='#0000FF'>operator</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> rhs.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> rhs.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>const</font> LHS<font color='#5555FF'>&amp;</font> lhs;
        <font color='#0000FF'>const</font> RHS<font color='#5555FF'>&amp;</font> rhs;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP1,
        <font color='#0000FF'>typename</font> EXP2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> matrix_add_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> matrix_add_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m1.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m2.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS, <font color='#0000FF'>typename</font> RHS<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_subtract_exp'></a>matrix_subtract_exp</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS, <font color='#0000FF'>typename</font> RHS<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> LHS::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>RHS::NR <font color='#5555FF'>&gt;</font> LHS::NR<font face='Lucida Console'>)</font> ? RHS::NR : LHS::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>RHS::NC <font color='#5555FF'>&gt;</font> LHS::NC<font face='Lucida Console'>)</font> ? RHS::NC : LHS::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> LHS::cost<font color='#5555FF'>+</font>RHS::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> LHS,
        <font color='#0000FF'>typename</font> RHS
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_subtract_exp'></a>matrix_subtract_exp</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&lt;</font>LHS,RHS<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#009900'>/*!
            REQUIREMENTS ON LHS AND RHS
                - must be matrix_exp objects. 
        !*/</font>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::cost;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::layout_type layout_type;


        <font color='#009900'>// This constructor exists simply for the purpose of causing a compile time error if
</font>        <font color='#009900'>// someone tries to create an instance of this object with the wrong kind of objects.
</font>        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T1, <font color='#0000FF'>typename</font> T2<font color='#5555FF'>&gt;</font>
        <b><a name='matrix_subtract_exp'></a>matrix_subtract_exp</b> <font face='Lucida Console'>(</font>T1,T2<font face='Lucida Console'>)</font>; 

        <b><a name='matrix_subtract_exp'></a>matrix_subtract_exp</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> LHS<font color='#5555FF'>&amp;</font> lhs_,
            <font color='#0000FF'>const</font> RHS<font color='#5555FF'>&amp;</font> rhs_
        <font face='Lucida Console'>)</font> : 
            lhs<font face='Lucida Console'>(</font>lhs_<font face='Lucida Console'>)</font>,
            rhs<font face='Lucida Console'>(</font>rhs_<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// You can only subtract one matrix from another if they both have the same number of rows and columns.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>LHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> RHS::NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> LHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> RHS::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>LHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> RHS::NC <font color='#5555FF'>|</font><font color='#5555FF'>|</font> LHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> RHS::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                   lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, 
                "<font color='#CC0000'>\tconst matrix_exp operator-(const matrix_exp&amp; lhs, const matrix_exp&amp; rhs)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou are trying to subtract two incompatible matrices</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlhs.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlhs.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trhs.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trhs.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t&amp;lhs: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#5555FF'>&amp;</font>lhs 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t&amp;rhs: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#5555FF'>&amp;</font>rhs 
                <font face='Lucida Console'>)</font>;

            <font color='#009900'>// You can only subtract one matrix from another if they both contain elements of the same type.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> LHS::type, <font color='#0000FF'>typename</font> RHS::type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>lhs</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> <font color='#BB00BB'>rhs</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>long</u></font> i <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> <font color='#0000FF'>return</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_subtract_exp<font color='#5555FF'>&gt;</font>::<font color='#0000FF'>operator</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> rhs.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> rhs.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> lhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>const</font> LHS<font color='#5555FF'>&amp;</font> lhs;
        <font color='#0000FF'>const</font> RHS<font color='#5555FF'>&amp;</font> rhs;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP1,
        <font color='#0000FF'>typename</font> EXP2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> matrix_subtract_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> matrix_subtract_exp<font color='#5555FF'>&lt;</font>EXP1, EXP2<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m1.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m2.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_div_scal_exp'></a>matrix_div_scal_exp</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> M::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> M::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> M::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> M
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_div_scal_exp'></a>matrix_div_scal_exp</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#009900'>/*!
            REQUIREMENTS ON M 
                - must be a matrix_exp object.
        !*/</font>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::cost;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::layout_type layout_type;


        <font color='#009900'>// This constructor exists simply for the purpose of causing a compile time error if
</font>        <font color='#009900'>// someone tries to create an instance of this object with the wrong kind of objects.
</font>        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T1<font color='#5555FF'>&gt;</font>
        <b><a name='matrix_div_scal_exp'></a>matrix_div_scal_exp</b> <font face='Lucida Console'>(</font>T1, <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>; 

        <b><a name='matrix_div_scal_exp'></a>matrix_div_scal_exp</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m_,
            <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font> s_
        <font face='Lucida Console'>)</font> :
            m<font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>,
            s<font face='Lucida Console'>(</font>s_<font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font><font color='#5555FF'>/</font>s; <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>long</u></font> i <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> <font color='#0000FF'>return</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_div_scal_exp<font color='#5555FF'>&gt;</font>::<font color='#0000FF'>operator</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m;
        <font color='#0000FF'>const</font> type s;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> S
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> enable_if_c<font color='#5555FF'>&lt;</font>std::numeric_limits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type<font color='#5555FF'>&gt;</font>::is_integer, matrix_div_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>/</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> matrix_div_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M, <font color='#0000FF'><u>bool</u></font> use_reference <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>M,use_reference<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> M::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> M::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> M::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T, <font color='#0000FF'><u>bool</u></font> is_ref<font color='#5555FF'>&gt;</font> <font color='#0000FF'>struct</font> <b><a name='conditional_reference'></a>conditional_reference</b> <b>{</b> <font color='#0000FF'>typedef</font> T type; <b>}</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font> <font color='#0000FF'>struct</font> <b><a name='conditional_reference'></a>conditional_reference</b><font color='#5555FF'>&lt;</font>T,<font color='#979000'>true</font><font color='#5555FF'>&gt;</font>      <b>{</b> <font color='#0000FF'>typedef</font> T<font color='#5555FF'>&amp;</font> type; <b>}</b>;


    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> M,
        <font color='#0000FF'><u>bool</u></font> use_reference
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix_mul_scal_exp'></a>matrix_mul_scal_exp</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>M,use_reference<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#009900'>/*!
            REQUIREMENTS ON M 
                - must be a matrix_exp object.

        !*/</font>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::cost;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::layout_type layout_type;

        <font color='#009900'>// You aren't allowed to multiply a matrix of matrices by a scalar.   
</font>        <b><a name='COMPILE_TIME_ASSERT'></a>COMPILE_TIME_ASSERT</b><font face='Lucida Console'>(</font>is_matrix<font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>;

        <font color='#009900'>// This constructor exists simply for the purpose of causing a compile time error if
</font>        <font color='#009900'>// someone tries to create an instance of this object with the wrong kind of objects.
</font>        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T1<font color='#5555FF'>&gt;</font>
        <b><a name='matrix_mul_scal_exp'></a>matrix_mul_scal_exp</b> <font face='Lucida Console'>(</font>T1, <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font><font face='Lucida Console'>)</font>; 

        <b><a name='matrix_mul_scal_exp'></a>matrix_mul_scal_exp</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m_,
            <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font> s_
        <font face='Lucida Console'>)</font> :
            m<font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>,
            s<font face='Lucida Console'>(</font>s_<font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>s; <b>}</b>

        <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>long</u></font> i <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> <font color='#0000FF'>return</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_mul_scal_exp<font color='#5555FF'>&gt;</font>::<font color='#0000FF'>operator</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> conditional_reference<font color='#5555FF'>&lt;</font><font color='#0000FF'>const</font> M,use_reference<font color='#5555FF'>&gt;</font>::type M_ref_type;

        M_ref_type m;
        <font color='#0000FF'>const</font> type s;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> S 
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>S<font color='#5555FF'>&gt;</font>, <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> S,
        <font color='#0000FF'><u>bool</u></font> B
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>S<font color='#5555FF'>&gt;</font>, <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP,B<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.m,<font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>m.s<font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> S 
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>S<font color='#5555FF'>&gt;</font>, <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> S,
        <font color='#0000FF'><u>bool</u></font> B
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>S<font color='#5555FF'>&gt;</font>, <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>*</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s,
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP,B<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.m,<font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font color='#5555FF'>*</font>m.s<font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP ,
        <font color='#0000FF'>typename</font> S
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if_c<font color='#5555FF'>&lt;</font>std::numeric_limits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type<font color='#5555FF'>&gt;</font>::is_integer, matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>/</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>const</font> type one <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,one<font color='#5555FF'>/</font><font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'><u>bool</u></font> B,
        <font color='#0000FF'>typename</font> S
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if_c<font color='#5555FF'>&lt;</font>std::numeric_limits<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type<font color='#5555FF'>&gt;</font>::is_integer, matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>/</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP,B<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> s
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.m,m.s<font color='#5555FF'>/</font><font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>s<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='op_s_div_m'></a>op_s_div_m</b> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font> 
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type type;

        <b><a name='op_s_div_m'></a>op_s_div_m</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m_, <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font> s_<font face='Lucida Console'>)</font> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>, s<font face='Lucida Console'>(</font>s_<font face='Lucida Console'>)</font><b>{</b><b>}</b>

        <font color='#0000FF'>const</font> type s;

        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> M::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> M::type const_ret_type;
        const_ret_type <b><a name='apply'></a>apply</b> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r, <font color='#0000FF'><u>long</u></font> c<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b> 
            <font color='#0000FF'>return</font> s<font color='#5555FF'>/</font><font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>&gt;</font><font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> S
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>S<font color='#5555FF'>&gt;</font>, matrix_op<font color='#5555FF'>&lt;</font>op_s_div_m<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>/</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> S<font color='#5555FF'>&amp;</font> val,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;

        <font color='#0000FF'>typedef</font> op_s_div_m<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> op;
        <font color='#0000FF'>return</font> matrix_op<font color='#5555FF'>&lt;</font>op<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>op</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>val<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#5555FF'>-</font><font color='#979000'>1</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'><u>bool</u></font> B
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP,B<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> matrix_mul_scal_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m.m,<font color='#5555FF'>-</font><font color='#979000'>1</font><font color='#5555FF'>*</font>m.s<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='op_add_scalar'></a>op_add_scalar</b> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font> 
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type type;

        <b><a name='op_add_scalar'></a>op_add_scalar</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m_, <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font> s_<font face='Lucida Console'>)</font> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>, s<font face='Lucida Console'>(</font>s_<font face='Lucida Console'>)</font><b>{</b><b>}</b>

        <font color='#0000FF'>const</font> type s;

        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> M::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> M::type const_ret_type;
        const_ret_type <b><a name='apply'></a>apply</b> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r, <font color='#0000FF'><u>long</u></font> c<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b> 
            <font color='#0000FF'>return</font> <font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>&gt;</font><font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font> s;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>, matrix_op<font color='#5555FF'>&lt;</font>op_add_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> val
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;

        <font color='#0000FF'>typedef</font> op_add_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> op;
        <font color='#0000FF'>return</font> matrix_op<font color='#5555FF'>&lt;</font>op<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>op</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>val<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>, matrix_op<font color='#5555FF'>&lt;</font>op_add_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>+</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> val,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;

        <font color='#0000FF'>typedef</font> op_add_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> op;
        <font color='#0000FF'>return</font> matrix_op<font color='#5555FF'>&lt;</font>op<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>op</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>val<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='op_subl_scalar'></a>op_subl_scalar</b> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font> 
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type type;

        <b><a name='op_subl_scalar'></a>op_subl_scalar</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m_, <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font> s_<font face='Lucida Console'>)</font> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>, s<font face='Lucida Console'>(</font>s_<font face='Lucida Console'>)</font><b>{</b><b>}</b>

        <font color='#0000FF'>const</font> type s;

        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> M::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> M::type const_ret_type;
        const_ret_type <b><a name='apply'></a>apply</b> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r, <font color='#0000FF'><u>long</u></font> c<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b> 
            <font color='#0000FF'>return</font> s <font color='#5555FF'>-</font> <font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>&gt;</font><font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> ;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>, matrix_op<font color='#5555FF'>&lt;</font>op_subl_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> val,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;

        <font color='#0000FF'>typedef</font> op_subl_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> op;
        <font color='#0000FF'>return</font> matrix_op<font color='#5555FF'>&lt;</font>op<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>op</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>val<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> M<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='op_subr_scalar'></a>op_subr_scalar</b> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font> 
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> M::type type;

        <b><a name='op_subr_scalar'></a>op_subr_scalar</b><font face='Lucida Console'>(</font> <font color='#0000FF'>const</font> M<font color='#5555FF'>&amp;</font> m_, <font color='#0000FF'>const</font> type<font color='#5555FF'>&amp;</font> s_<font face='Lucida Console'>)</font> : basic_op_m<font color='#5555FF'>&lt;</font>M<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>, s<font face='Lucida Console'>(</font>s_<font face='Lucida Console'>)</font><b>{</b><b>}</b>

        <font color='#0000FF'>const</font> type s;

        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> M::cost<font color='#5555FF'>+</font><font color='#979000'>1</font>;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> M::type const_ret_type;
        const_ret_type <b><a name='apply'></a>apply</b> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r, <font color='#0000FF'><u>long</u></font> c<font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b> 
            <font color='#0000FF'>return</font> <font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>&gt;</font><font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font> s;
        <b>}</b>
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP,
        <font color='#0000FF'>typename</font> T
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>const</font> <font color='#0000FF'>typename</font> disable_if<font color='#5555FF'>&lt;</font>is_matrix<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font>, matrix_op<font color='#5555FF'>&lt;</font>op_subr_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>::type <b><a name='operator'></a>operator</b><font color='#5555FF'>-</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m,
        <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> val
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;

        <font color='#0000FF'>typedef</font> op_subr_scalar<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> op;
        <font color='#0000FF'>return</font> matrix_op<font color='#5555FF'>&lt;</font>op<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#BB00BB'>op</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>ref</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>type<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>val<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP1,
        <font color='#0000FF'>typename</font> EXP2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>bool</u></font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>m1.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m2.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> m1.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m2.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> m1.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> m1.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>m1</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#BB00BB'>m2</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                        <font color='#0000FF'>return</font> <font color='#979000'>false</font>;
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#979000'>true</font>;
        <b>}</b>
        <font color='#0000FF'>return</font> <font color='#979000'>false</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP1,
        <font color='#0000FF'>typename</font> EXP2
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>inline</font> <font color='#0000FF'><u>bool</u></font> <b><a name='operator'></a>operator</b><font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP1<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m1,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP2<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m2
    <font face='Lucida Console'>)</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#5555FF'>!</font><font face='Lucida Console'>(</font>m1 <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m2<font face='Lucida Console'>)</font>; <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='op_pointer_to_mat'></a>op_pointer_to_mat</b>;
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> T<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='op_pointer_to_col_vect'></a>op_pointer_to_col_vect</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> num_rows,
        <font color='#0000FF'><u>long</u></font> num_cols,
        <font color='#0000FF'>typename</font> mem_manager,
        <font color='#0000FF'>typename</font> layout
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font>T,num_rows, num_cols, mem_manager, layout<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> T type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> const_ret_type;
        <font color='#0000FF'>typedef</font> mem_manager mem_manager_type;
        <font color='#0000FF'>typedef</font> layout layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> num_rows;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> num_cols;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> <font color='#979000'>1</font>;

    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> num_rows,
        <font color='#0000FF'><u>long</u></font> num_cols,
        <font color='#0000FF'>typename</font> mem_manager,
        <font color='#0000FF'>typename</font> layout
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='matrix'></a>matrix</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font>T,num_rows,num_cols, mem_manager,layout<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> 
    <b>{</b>

        <b><a name='COMPILE_TIME_ASSERT'></a>COMPILE_TIME_ASSERT</b><font face='Lucida Console'>(</font>num_rows <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> num_cols <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>; 

    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font>::cost;
        <font color='#0000FF'>typedef</font> T<font color='#5555FF'>*</font>          iterator;       
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>const</font> T<font color='#5555FF'>*</font>    const_iterator; 

        <b><a name='matrix'></a>matrix</b> <font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
        <b>{</b>
        <b>}</b>

        <font color='#0000FF'>explicit</font> <b><a name='matrix'></a>matrix</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> length 
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#009900'>// This object you are trying to call matrix(length) on is not a column or 
</font>            <font color='#009900'>// row vector.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> length <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tmatrix::matrix(length)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength must be at least 0</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> length 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> length,
                    "<font color='#CC0000'>\tmatrix::matrix(length)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tSince this is a statically sized matrix length must equal NC</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> length 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                    <font face='Lucida Console'>)</font>;

                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>,length<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> length,
                    "<font color='#CC0000'>\tvoid matrix::set_size(length)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tSince this is a statically sized matrix length must equal NR</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> length 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                    <font face='Lucida Console'>)</font>;

                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>length,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        <b><a name='matrix'></a>matrix</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> rows,
            <font color='#0000FF'><u>long</u></font> cols 
        <font face='Lucida Console'>)</font>  
        <b>{</b>
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rows<font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font face='Lucida Console'>(</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> cols<font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> 
                    rows <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> cols <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tvoid matrix::matrix(rows, cols)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou have supplied conflicting matrix dimensions</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trows: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rows
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tcols: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cols
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                <font face='Lucida Console'>)</font>;
            data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>rows,cols<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        <b><a name='matrix'></a>matrix</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// You get an error on this line if the matrix m contains a type that isn't
</font>            <font color='#009900'>// the same as the type contained in the target matrix.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type,type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
                                <font face='Lucida Console'>(</font>is_matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#009900'>// The matrix you are trying to assign m to is a statically sized matrix and 
</font>            <font color='#009900'>// m's dimensions don't match that of *this. 
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NC <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, 
                "<font color='#CC0000'>\tmatrix&amp; matrix::matrix(const matrix_exp&amp; m)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou are trying to assign a dynamically sized matrix to a statically sized matrix with the wrong size</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tm.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tm.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;

            <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, m<font face='Lucida Console'>)</font>;
        <b>}</b>

        <b><a name='matrix'></a>matrix</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font> : matrix_exp<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font> 
        <b>{</b>
            data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, m<font face='Lucida Console'>)</font>;
        <b>}</b>

<font color='#0000FF'>#ifdef</font> DLIB_HAS_INITIALIZER_LISTS
        <b><a name='matrix'></a>matrix</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> std::initializer_list<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> l<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NR<font color='#5555FF'>*</font>NC <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NR<font color='#5555FF'>*</font>NC, 
                    "<font color='#CC0000'>\t matrix::matrix(const std::initializer_list&amp; l)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to initialize a statically sized matrix with a list that doesn't have a matching size.</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t l.size(): </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t NR*NC:    </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR<font color='#5555FF'>*</font>NC<font face='Lucida Console'>)</font>;

                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>NR, NC<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NR<font color='#5555FF'>!</font><font color='#5555FF'>=</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> 
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>%</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                    "<font color='#CC0000'>\t matrix::matrix(const std::initializer_list&amp; l)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to initialize a statically sized matrix with a list that doesn't have a compatible size.</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t l.size(): </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t NR:       </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR<font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                    data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>NR, l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font>NR<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NC<font color='#5555FF'>!</font><font color='#5555FF'>=</font><font color='#979000'>0</font><font face='Lucida Console'>)</font> 
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>%</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                    "<font color='#CC0000'>\t matrix::matrix(const std::initializer_list&amp; l)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to initialize a statically sized matrix with a list that doesn't have a compatible size.</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t l.size(): </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t NC:       </font>"<font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC<font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                    data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>/</font>NC, NC<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font> <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            <b>{</b>
                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <b>}</b>

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>l.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            <b>{</b>
                T<font color='#5555FF'>*</font> d <font color='#5555FF'>=</font> <font color='#5555FF'>&amp;</font><font color='#BB00BB'>data</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'>auto</font><font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> v : l<font face='Lucida Console'>)</font>
                    <font color='#5555FF'>*</font>d<font color='#5555FF'>+</font><font color='#5555FF'>+</font> <font color='#5555FF'>=</font> v;
            <b>}</b>

        <b>}</b>

        std::unique_ptr<font color='#5555FF'>&lt;</font>T[]<font color='#5555FF'>&gt;</font> <b><a name='steal_memory'></a>steal_memory</b><font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>return</font> data.<font color='#BB00BB'>steal_memory</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> std::initializer_list<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> l<font face='Lucida Console'>)</font>
        <b>{</b>
            matrix <font color='#BB00BB'>temp</font><font face='Lucida Console'>(</font>l<font face='Lucida Console'>)</font>;
            temp.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_HAS_INITIALIZER_LISTS
</font>
<font color='#0000FF'>#ifdef</font> DLIB_HAS_RVALUE_REFERENCES
        <b><a name='matrix'></a>matrix</b><font face='Lucida Console'>(</font>matrix<font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> item<font face='Lucida Console'>)</font>
        <b>{</b>
        <font color='#0000FF'>#ifdef</font> MATLAB_MEX_FILE
            <font color='#009900'>// You can't move memory around when compiled in a matlab mex file and the
</font>            <font color='#009900'>// different locations have different ownership settings.
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>data.<font color='#BB00BB'>_private_is_owned_by_matlab</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> item.data.<font color='#BB00BB'>_private_is_owned_by_matlab</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>item.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,item.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, item<font face='Lucida Console'>)</font>;
            <b>}</b>
        <font color='#0000FF'>#else</font>
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>#endif</font>
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            matrix<font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> rhs
        <font face='Lucida Console'>)</font>
        <b>{</b>
        <font color='#0000FF'>#ifdef</font> MATLAB_MEX_FILE
            <font color='#009900'>// You can't move memory around when compiled in a matlab mex file and the
</font>            <font color='#009900'>// different locations have different ownership settings.
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>data.<font color='#BB00BB'>_private_is_owned_by_matlab</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rhs.data.<font color='#BB00BB'>_private_is_owned_by_matlab</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>rhs<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>rhs.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,rhs.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, rhs<font face='Lucida Console'>)</font>;
            <b>}</b>
        <font color='#0000FF'>#else</font>
            <font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>rhs<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>#endif</font>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>
<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_HAS_RVALUE_REFERENCES
</font>
        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U, <font color='#0000FF'><u>size_t</u></font> len<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'>explicit</font> <b><a name='matrix'></a>matrix</b> <font face='Lucida Console'>(</font>
            <font color='#BB00BB'>U</font> <font face='Lucida Console'>(</font><font color='#5555FF'>&amp;</font>array<font face='Lucida Console'>)</font>[len]
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NR<font color='#5555FF'>*</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> len <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> len <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>size_t</u></font> idx <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> NR; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> NC; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>array[idx]<font face='Lucida Console'>)</font>;
                    <font color='#5555FF'>+</font><font color='#5555FF'>+</font>idx;
                <b>}</b>
            <b>}</b>
        <b>}</b>

        T<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> 
        <b>{</b> 
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>r <font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> c <font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                   r <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> c <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tT&amp; matrix::operator(r,c)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou must give a valid row and column</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tr:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> r 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tc:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> c
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>; 
        <b>}</b>

        <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> 
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>r <font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> c <font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                   r <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> c <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tconst T&amp; matrix::operator(r,c)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou must give a valid row and column</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tr:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> r 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tc:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> c
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>;
        <b>}</b>

        T<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> i
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#009900'>// You can only use this operator on column vectors.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font>, 
                "<font color='#CC0000'>\tconst type matrix::operator(i)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou can only use this operator on column or row vectors</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\ti:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> i
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#979000'>0</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> i <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> i <font color='#5555FF'>&lt;</font> <font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, 
                "<font color='#CC0000'>\tconst type matrix::operator(i)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou must give a valid row/column number</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\ti:      </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> i
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tsize(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> i
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#009900'>// You can only use this operator on column vectors.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font>, 
                "<font color='#CC0000'>\tconst type matrix::operator(i)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou can only use this operator on column or row vectors</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\ti:    </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> i
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#979000'>0</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> i <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> i <font color='#5555FF'>&lt;</font> <font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, 
                "<font color='#CC0000'>\tconst type matrix::operator(i)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou must give a valid row/column number</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\ti:      </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> i
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tsize(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>inline</font> <b><a name='operator'></a>operator</b> <font color='#0000FF'>const</font> <b><a name='type'></a>type</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> , 
                "<font color='#CC0000'>\tmatrix::operator const type</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou can only attempt to implicit convert a matrix to a scalar if</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthe matrix is a 1x1 matrix</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#0000FF'>return</font> <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>;
        <b>}</b>

<font color='#0000FF'>#ifdef</font> MATLAB_MEX_FILE
        <font color='#0000FF'><u>void</u></font> <b><a name='_private_set_mxArray'></a>_private_set_mxArray</b><font face='Lucida Console'>(</font>
            mxArray<font color='#5555FF'>*</font> mem 
        <font face='Lucida Console'>)</font>
        <b>{</b>
            data.<font color='#BB00BB'>_private_set_mxArray</font><font face='Lucida Console'>(</font>mem<font face='Lucida Console'>)</font>;
        <b>}</b>

        mxArray<font color='#5555FF'>*</font> <b><a name='_private_release_mxArray'></a>_private_release_mxArray</b><font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>return</font> data.<font color='#BB00BB'>_private_release_mxArray</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='_private_mark_owned_by_matlab'></a>_private_mark_owned_by_matlab</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
        <b>{</b>
            data.<font color='#BB00BB'>_private_mark_owned_by_matlab</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>bool</u></font> <b><a name='_private_is_owned_by_matlab'></a>_private_is_owned_by_matlab</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>return</font> data.<font color='#BB00BB'>_private_is_owned_by_matlab</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
        <b>}</b>
<font color='#0000FF'>#endif</font>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_size'></a>set_size</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> rows,
            <font color='#0000FF'><u>long</u></font> cols
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> <font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> rows<font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font face='Lucida Console'>(</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> cols<font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font>
                    rows <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> cols <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tvoid matrix::set_size(rows, cols)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou have supplied conflicting matrix dimensions</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\trows: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> rows
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tcols: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> cols
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> rows <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> cols<font face='Lucida Console'>)</font>
                data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>rows,cols<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='set_size'></a>set_size</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> length
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// This object you are trying to call set_size(length) on is not a column or 
</font>            <font color='#009900'>// row vector.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font> length <font color='#5555FF'>&gt;</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                "<font color='#CC0000'>\tvoid matrix::set_size(length)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength must be at least 0</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> length 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> length,
                    "<font color='#CC0000'>\tvoid matrix::set_size(length)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tSince this is a statically sized matrix length must equal NC</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> length 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                    <font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> length<font face='Lucida Console'>)</font>
                    data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font><font color='#979000'>1</font>,length<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> length,
                    "<font color='#CC0000'>\tvoid matrix::set_size(length)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tSince this is a statically sized matrix length must equal NR</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tlength: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> length 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNR:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NR 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tNC:     </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> NC 
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                    <font face='Lucida Console'>)</font>;

                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> length<font face='Lucida Console'>)</font>
                    data.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>length,<font color='#979000'>1</font><font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> data.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> data.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='size'></a>size</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> data.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>data.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U, <font color='#0000FF'><u>size_t</u></font> len<font color='#5555FF'>&gt;</font>
        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#BB00BB'>U</font> <font face='Lucida Console'>(</font><font color='#5555FF'>&amp;</font>array<font face='Lucida Console'>)</font>[len]
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>NR<font color='#5555FF'>*</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> len <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> len <font color='#5555FF'>&gt;</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'><u>size_t</u></font> idx <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> NR; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> NC; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>array[idx]<font face='Lucida Console'>)</font>;
                    <font color='#5555FF'>+</font><font color='#5555FF'>+</font>idx;
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// You get an error on this line if the matrix you are trying to 
</font>            <font color='#009900'>// assign m to is a statically sized matrix and  m's dimensions don't 
</font>            <font color='#009900'>// match that of *this. 
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NC <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> 
                   <font face='Lucida Console'>(</font>NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>, 
                "<font color='#CC0000'>\tmatrix&amp; matrix::operator=(const matrix_exp&amp; m)</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tYou are trying to assign a dynamically sized matrix to a statically sized matrix with the wrong size</font>"
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnr():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tnc():   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tm.nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tm.nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\tthis:   </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#0000FF'>this</font>
                <font face='Lucida Console'>)</font>;

            <font color='#009900'>// You get an error on this line if the matrix m contains a type that isn't
</font>            <font color='#009900'>// the same as the type contained in the target matrix.
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type,type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font>
                                <font face='Lucida Console'>(</font>is_matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>m.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#009900'>// This if statement is seemingly unnecessary since set_size() contains this
</font>                <font color='#009900'>// exact same if statement.  However, structuring the code this way causes
</font>                <font color='#009900'>// gcc to handle the way it inlines this function in a much more favorable way.
</font>                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>data.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> data.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, m<font face='Lucida Console'>)</font>;
                <b>}</b>
                <font color='#0000FF'>else</font>
                <b>{</b>
                    <font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, m<font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#009900'>// we have to use a temporary matrix object here because
</font>                <font color='#009900'>// *this is aliased inside the matrix_exp m somewhere.
</font>                matrix temp;
                temp.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font>temp, m<font face='Lucida Console'>)</font>;
                temp.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// The matrix you are trying to assign m to is a statically sized matrix and 
</font>            <font color='#009900'>// m's dimensions don't match that of *this. 
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NC <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type,type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>m.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>+</font> m<font face='Lucida Console'>)</font>;
                <b>}</b>
                <font color='#0000FF'>else</font>
                <b>{</b>
                    <font color='#009900'>// we have to use a temporary matrix object here because
</font>                    <font color='#009900'>// this-&gt;data is aliased inside the matrix_exp m somewhere.
</font>                    matrix temp;
                    temp.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font>temp, <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>+</font> m<font face='Lucida Console'>)</font>;
                    temp.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                    "<font color='#CC0000'>\t const matrix::operator+=(m)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to add two matrices that have incompatible dimensions.</font>"<font face='Lucida Console'>)</font>;
                <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font> m;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>


        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>-</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#009900'>// The matrix you are trying to assign m to is a statically sized matrix and 
</font>            <font color='#009900'>// m's dimensions don't match that of *this. 
</font>            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NR <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NR <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font>EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> NC <font color='#5555FF'>|</font><font color='#5555FF'>|</font> NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> EXP::NC <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>COMPILE_TIME_ASSERT</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font>is_same_type<font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP::type,type<font color='#5555FF'>&gt;</font>::value <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>true</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>m.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>false</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font>, <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>-</font> m<font face='Lucida Console'>)</font>;
                <b>}</b>
                <font color='#0000FF'>else</font>
                <b>{</b>
                    <font color='#009900'>// we have to use a temporary matrix object here because
</font>                    <font color='#009900'>// this-&gt;data is aliased inside the matrix_exp m somewhere.
</font>                    matrix temp;
                    temp.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                    <font color='#BB00BB'>matrix_assign</font><font face='Lucida Console'>(</font>temp, <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>-</font> m<font face='Lucida Console'>)</font>;
                    temp.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font><font color='#5555FF'>*</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                    "<font color='#CC0000'>\t const matrix::operator-=(m)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to subtract two matrices that have incompatible dimensions.</font>"<font face='Lucida Console'>)</font>;
                <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>m;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>*</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>*</font> m;
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> size <font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>&gt;</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                    "<font color='#CC0000'>\t const matrix::operator+=(m)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to add two matrices that have incompatible dimensions.</font>"<font face='Lucida Console'>)</font>;

                <font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> m.<font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>-</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> size <font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> <font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>else</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_ASSERT</font><font face='Lucida Console'>(</font><font color='#0000FF'>this</font><font color='#5555FF'>-</font><font color='#5555FF'>&gt;</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#979000'>0</font>, 
                    "<font color='#CC0000'>\t const matrix::operator-=(m)</font>"
                    <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t You are trying to subtract two matrices that have incompatible dimensions.</font>"<font face='Lucida Console'>)</font>;
                <font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> <font color='#5555FF'>-</font>m.<font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> T val
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>size_t</u></font> size <font color='#5555FF'>=</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font><font face='Lucida Console'>)</font><font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>+</font><font color='#5555FF'>=</font> val;

            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>-</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> T val
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>const</font> <font color='#0000FF'><u>size_t</u></font> size <font color='#5555FF'>=</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font><font face='Lucida Console'>)</font><font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>-</font><font color='#5555FF'>=</font> val;

            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>*</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> T a
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>*</font> a;
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>/</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> T a
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>/</font> a;
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix<font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#0000FF'>this</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#5555FF'>&amp;</font>m<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>const</font> <font color='#0000FF'><u>long</u></font> size <font color='#5555FF'>=</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                    <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> m.<font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>;
            <b>}</b>
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        <font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b> <font face='Lucida Console'>(</font>
            matrix<font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font>
        <b>{</b>
            data.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>item.data<font face='Lucida Console'>)</font>;
        <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> 
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>false</font>; <b>}</b>

        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font>T,num_rows,num_cols, mem_manager,layout<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font face='Lucida Console'>(</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font color='#5555FF'>&amp;</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> 
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#979000'>false</font>; <b>}</b>

        <font color='#009900'>// These two aliases() routines are defined in matrix_mat.h
</font>        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_op<font color='#5555FF'>&lt;</font>op_pointer_to_mat<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>matrix_op<font color='#5555FF'>&lt;</font>op_pointer_to_col_vect<font color='#5555FF'>&lt;</font>T<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>;

        iterator <b><a name='begin'></a>begin</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#5555FF'>&amp;</font><font color='#BB00BB'>data</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>else</font>
                <font color='#0000FF'>return</font> <font color='#979000'>0</font>;
        <b>}</b>

        iterator <b><a name='end'></a>end</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#5555FF'>&amp;</font><font color='#BB00BB'>data</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>else</font>
                <font color='#0000FF'>return</font> <font color='#979000'>0</font>;
        <b>}</b>

        const_iterator <b><a name='begin'></a>begin</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>  <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#5555FF'>&amp;</font><font color='#BB00BB'>data</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>else</font>
                <font color='#0000FF'>return</font> <font color='#979000'>0</font>;
        <b>}</b>

        const_iterator <b><a name='end'></a>end</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
        <b>{</b>
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
                <font color='#0000FF'>return</font> <font color='#5555FF'>&amp;</font><font color='#BB00BB'>data</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font color='#5555FF'>+</font><font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>else</font>
                <font color='#0000FF'>return</font> <font color='#979000'>0</font>;
        <b>}</b>

    <font color='#0000FF'>private</font>:
        <font color='#0000FF'>struct</font> <b><a name='literal_assign_helper'></a>literal_assign_helper</b>
        <b>{</b>
            <font color='#009900'>/*
                This struct is a helper struct returned by the operator&lt;&lt;() function below.  It is
                used primarily to enable us to put DLIB_CASSERT statements on the usage of the
                operator&lt;&lt; form of matrix assignment.
            */</font>

            <b><a name='literal_assign_helper'></a>literal_assign_helper</b><font face='Lucida Console'>(</font><font color='#0000FF'>const</font> literal_assign_helper<font color='#5555FF'>&amp;</font> item<font face='Lucida Console'>)</font> : m<font face='Lucida Console'>(</font>item.m<font face='Lucida Console'>)</font>, r<font face='Lucida Console'>(</font>item.r<font face='Lucida Console'>)</font>, c<font face='Lucida Console'>(</font>item.c<font face='Lucida Console'>)</font>, has_been_used<font face='Lucida Console'>(</font><font color='#979000'>false</font><font face='Lucida Console'>)</font> <b>{</b><b>}</b>
            <font color='#0000FF'>explicit</font> <b><a name='literal_assign_helper'></a>literal_assign_helper</b><font face='Lucida Console'>(</font>matrix<font color='#5555FF'>*</font> m_<font face='Lucida Console'>)</font>: m<font face='Lucida Console'>(</font>m_<font face='Lucida Console'>)</font>, r<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>, c<font face='Lucida Console'>(</font><font color='#979000'>0</font><font face='Lucida Console'>)</font>,has_been_used<font face='Lucida Console'>(</font><font color='#979000'>false</font><font face='Lucida Console'>)</font> <b>{</b><font color='#BB00BB'>next</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;<b>}</b>
            ~<b><a name='literal_assign_helper'></a>literal_assign_helper</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <b><a name='noexcept'></a>noexcept</b><font face='Lucida Console'>(</font><font color='#979000'>false</font><font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font><font color='#5555FF'>!</font>has_been_used <font color='#5555FF'>|</font><font color='#5555FF'>|</font> r <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font>.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
                             "<font color='#CC0000'>You have used the matrix comma based assignment incorrectly by failing to\n</font>"
                             "<font color='#CC0000'>supply a full set of values for every element of a matrix object.\n</font>"<font face='Lucida Console'>)</font>;
            <b>}</b>

            <font color='#0000FF'>const</font> literal_assign_helper<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b>, <font face='Lucida Console'>(</font>
                <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> val
            <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
            <b>{</b>
                <font color='#BB00BB'>DLIB_CASSERT</font><font face='Lucida Console'>(</font>r <font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font>.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> c <font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font>.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
                             "<font color='#CC0000'>You have used the matrix comma based assignment incorrectly by attempting to\n</font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>
                             "<font color='#CC0000'>supply more values than there are elements in the matrix object being assigned to.\n\n</font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font>
                             "<font color='#CC0000'>Did you forget to call set_size()?</font>" 
                             <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t r: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> r 
                             <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t c: </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> c 
                             <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t m-&gt;nr(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font>.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
                             <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n\t m-&gt;nc(): </font>" <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font>.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> val;
                <font color='#BB00BB'>next</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
                has_been_used <font color='#5555FF'>=</font> <font color='#979000'>true</font>;
                <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
            <b>}</b>

        <font color='#0000FF'>private</font>:

            <font color='#0000FF'>friend</font> <font color='#0000FF'>class</font> <b><a name='matrix'></a>matrix</b><font color='#5555FF'>&lt;</font>T,num_rows,num_cols,mem_manager,layout<font color='#5555FF'>&gt;</font>;

            <font color='#0000FF'><u>void</u></font> <b><a name='next'></a>next</b> <font face='Lucida Console'>(</font>
            <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font>
            <b>{</b>
                <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c;
                <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>c <font color='#5555FF'>=</font><font color='#5555FF'>=</font> <font face='Lucida Console'>(</font><font color='#5555FF'>*</font>m<font face='Lucida Console'>)</font>.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                <b>{</b>
                    c <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
                    <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r;
                <b>}</b>
            <b>}</b>

            matrix<font color='#5555FF'>*</font> m;
            <font color='#0000FF'>mutable</font> <font color='#0000FF'><u>long</u></font> r;
            <font color='#0000FF'>mutable</font> <font color='#0000FF'><u>long</u></font> c;
            <font color='#0000FF'>mutable</font> <font color='#0000FF'><u>bool</u></font> has_been_used;
        <b>}</b>;

    <font color='#0000FF'>public</font>:

        matrix<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> literal_assign_helper<font color='#5555FF'>&amp;</font> val
        <font face='Lucida Console'>)</font> 
        <b>{</b>  
            <font color='#5555FF'>*</font><font color='#0000FF'>this</font> <font color='#5555FF'>=</font> <font color='#5555FF'>*</font>val.m;
            <font color='#0000FF'>return</font> <font color='#5555FF'>*</font><font color='#0000FF'>this</font>;
        <b>}</b>

        <font color='#0000FF'>const</font> literal_assign_helper <b><a name='operator'></a>operator</b> <font color='#5555FF'>=</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> T<font color='#5555FF'>&amp;</font> val
        <font face='Lucida Console'>)</font> 
        <b>{</b>  
            <font color='#009900'>// assign the given value to every spot in this matrix
</font>            <font color='#0000FF'>const</font> <font color='#0000FF'><u>size_t</u></font> size <font color='#5555FF'>=</font> <font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font><font face='Lucida Console'>)</font><font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>size_t</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> size; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>i<font face='Lucida Console'>)</font>
                <font color='#BB00BB'>data</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font> <font color='#5555FF'>=</font> val;

            <font color='#009900'>// Now return the literal_assign_helper so that the user
</font>            <font color='#009900'>// can use the overloaded comma notation to initialize 
</font>            <font color='#009900'>// the matrix if they want to.
</font>            <font color='#0000FF'>return</font> <font color='#BB00BB'>literal_assign_helper</font><font face='Lucida Console'>(</font><font color='#0000FF'>this</font><font face='Lucida Console'>)</font>; 
        <b>}</b>

    <font color='#0000FF'>private</font>:


        <font color='#0000FF'>typename</font> layout::<font color='#0000FF'>template</font> layout<font color='#5555FF'>&lt;</font>T,NR,NC,mem_manager<font color='#5555FF'>&gt;</font> data;
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> NR,
        <font color='#0000FF'><u>long</u></font> NC,
        <font color='#0000FF'>typename</font> mm,
        <font color='#0000FF'>typename</font> l
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='swap'></a>swap</b><font face='Lucida Console'>(</font>
        matrix<font color='#5555FF'>&lt;</font>T,NR,NC,mm,l<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> a,
        matrix<font color='#5555FF'>&lt;</font>T,NR,NC,mm,l<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> b
    <font face='Lucida Console'>)</font> <b>{</b> a.<font color='#BB00BB'>swap</font><font face='Lucida Console'>(</font>b<font face='Lucida Console'>)</font>; <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> NR,
        <font color='#0000FF'><u>long</u></font> NC,
        <font color='#0000FF'>typename</font> mm,
        <font color='#0000FF'>typename</font> l
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> matrix<font color='#5555FF'>&lt;</font>T,NR,NC,mm,l<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item, 
        std::ostream<font color='#5555FF'>&amp;</font> out
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>try</font>
        <b>{</b>
            <font color='#009900'>// The reason the serialization is a little funny is because we are trying to
</font>            <font color='#009900'>// maintain backwards compatibility with an older serialization format used by
</font>            <font color='#009900'>// dlib while also encoding things in a way that lets the array2d and matrix
</font>            <font color='#009900'>// objects have compatible serialization formats.
</font>            <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font><font color='#5555FF'>-</font>item.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,out<font face='Lucida Console'>)</font>;
            <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font><font color='#5555FF'>-</font>item.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,out<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> item.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> item.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font><font color='#BB00BB'>item</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>,out<font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
        <b>}</b>
        <font color='#0000FF'>catch</font> <font face='Lucida Console'>(</font>serialization_error<font color='#5555FF'>&amp;</font> e<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>throw</font> <font color='#BB00BB'>serialization_error</font><font face='Lucida Console'>(</font>e.info <font color='#5555FF'>+</font> "<font color='#CC0000'>\n   while serializing dlib::matrix</font>"<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> NR,
        <font color='#0000FF'><u>long</u></font> NC,
        <font color='#0000FF'>typename</font> mm,
        <font color='#0000FF'>typename</font> l
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
        matrix<font color='#5555FF'>&lt;</font>T,NR,NC,mm,l<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item, 
        std::istream<font color='#5555FF'>&amp;</font> in
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>try</font>
        <b>{</b>
            <font color='#0000FF'><u>long</u></font> nr, nc;
            <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>nr,in<font face='Lucida Console'>)</font>; 
            <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>nc,in<font face='Lucida Console'>)</font>; 

            <font color='#009900'>// this is the newer serialization format
</font>            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>nr <font color='#5555FF'>&lt;</font> <font color='#979000'>0</font> <font color='#5555FF'>|</font><font color='#5555FF'>|</font> nc <font color='#5555FF'>&lt;</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            <b>{</b>
                nr <font color='#5555FF'>*</font><font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>;
                nc <font color='#5555FF'>*</font><font color='#5555FF'>=</font> <font color='#5555FF'>-</font><font color='#979000'>1</font>;
            <b>}</b>

            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NR <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> nr <font color='#5555FF'>!</font><font color='#5555FF'>=</font> NR<font face='Lucida Console'>)</font>
                <font color='#0000FF'>throw</font> <font color='#BB00BB'>serialization_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Error while deserializing a dlib::matrix.  Invalid rows</font>"<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>NC <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font> <font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> nc <font color='#5555FF'>!</font><font color='#5555FF'>=</font> NC<font face='Lucida Console'>)</font>
                <font color='#0000FF'>throw</font> <font color='#BB00BB'>serialization_error</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>Error while deserializing a dlib::matrix.  Invalid columns</font>"<font face='Lucida Console'>)</font>;

            item.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>nr,nc<font face='Lucida Console'>)</font>;
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> nr; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> nc; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font><font color='#BB00BB'>item</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>,in<font face='Lucida Console'>)</font>;
                <b>}</b>
            <b>}</b>
        <b>}</b>
        <font color='#0000FF'>catch</font> <font face='Lucida Console'>(</font>serialization_error<font color='#5555FF'>&amp;</font> e<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>throw</font> <font color='#BB00BB'>serialization_error</font><font face='Lucida Console'>(</font>e.info <font color='#5555FF'>+</font> "<font color='#CC0000'>\n   while deserializing a dlib::matrix</font>"<font face='Lucida Console'>)</font>;
        <b>}</b>
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> NR,
        <font color='#0000FF'><u>long</u></font> NC,
        <font color='#0000FF'>typename</font> mm,
        <font color='#0000FF'>typename</font> l
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='serialize'></a>serialize</b> <font face='Lucida Console'>(</font>
        <font color='#0000FF'>const</font> ramdump_t<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font>T,NR,NC,mm,l<font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item_, 
        std::ostream<font color='#5555FF'>&amp;</font> out
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>auto</font><font color='#5555FF'>&amp;</font> item <font color='#5555FF'>=</font> item_.item;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, out<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>serialize</font><font face='Lucida Console'>(</font>item.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>, out<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>item.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            out.<font color='#BB00BB'>write</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font><font color='#BB00BB'>item</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font><font color='#BB00BB'>item</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>item.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> T,
        <font color='#0000FF'><u>long</u></font> NR,
        <font color='#0000FF'><u>long</u></font> NC,
        <font color='#0000FF'>typename</font> mm,
        <font color='#0000FF'>typename</font> l
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'><u>void</u></font> <b><a name='deserialize'></a>deserialize</b> <font face='Lucida Console'>(</font>
        ramdump_t<font color='#5555FF'>&lt;</font>matrix<font color='#5555FF'>&lt;</font>T,NR,NC,mm,l<font color='#5555FF'>&gt;</font><font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font><font color='#5555FF'>&amp;</font> item_, 
        std::istream<font color='#5555FF'>&amp;</font> in 
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>auto</font><font color='#5555FF'>&amp;</font> item <font color='#5555FF'>=</font> item_.item;
        <font color='#0000FF'><u>long</u></font> nr, nc;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>nr, in<font face='Lucida Console'>)</font>;
        <font color='#BB00BB'>deserialize</font><font face='Lucida Console'>(</font>nc, in<font face='Lucida Console'>)</font>;
        item.<font color='#BB00BB'>set_size</font><font face='Lucida Console'>(</font>nr,nc<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>item.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font color='#5555FF'>!</font><font color='#5555FF'>=</font> <font color='#979000'>0</font><font face='Lucida Console'>)</font>
            in.<font color='#BB00BB'>read</font><font face='Lucida Console'>(</font><font face='Lucida Console'>(</font><font color='#0000FF'><u>char</u></font><font color='#5555FF'>*</font><font face='Lucida Console'>)</font><font color='#5555FF'>&amp;</font><font color='#BB00BB'>item</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font>, <font color='#0000FF'>sizeof</font><font face='Lucida Console'>(</font><font color='#BB00BB'>item</font><font face='Lucida Console'>(</font><font color='#979000'>0</font>,<font color='#979000'>0</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font><font color='#5555FF'>*</font>item.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP
        <font color='#5555FF'>&gt;</font>
    std::ostream<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font>
        std::ostream<font color='#5555FF'>&amp;</font> out,
        <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;
        <font color='#0000FF'>const</font> streamsize old <font color='#5555FF'>=</font> out.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;

        <font color='#009900'>// first figure out how wide we should make each field
</font>        string::size_type w <font color='#5555FF'>=</font> <font color='#979000'>0</font>;
        ostringstream sout;
        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
            <b>{</b>
                sout <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>; 
                w <font color='#5555FF'>=</font> std::<font color='#BB00BB'>max</font><font face='Lucida Console'>(</font>sout.<font color='#BB00BB'>str</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>.<font color='#BB00BB'>size</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,w<font face='Lucida Console'>)</font>;
                sout.<font color='#BB00BB'>str</font><font face='Lucida Console'>(</font>"<font color='#CC0000'></font>"<font face='Lucida Console'>)</font>;
            <b>}</b>
        <b>}</b>

        <font color='#009900'>// now actually print it
</font>        <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
            <b>{</b>
                out.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font><font color='#0000FF'>static_cast</font><font color='#5555FF'>&lt;</font>streamsize<font color='#5555FF'>&gt;</font><font face='Lucida Console'>(</font>w<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
                out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'> </font>";
            <b>}</b>
            out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n</font>";
        <b>}</b>
        out.<font color='#BB00BB'>width</font><font face='Lucida Console'>(</font>old<font face='Lucida Console'>)</font>;
        <font color='#0000FF'>return</font> out;
    <b>}</b>

    <font color='#009900'>/*
    template &lt;
        typename T, 
        long NR, 
        long NC,
        typename MM,
        typename L
        &gt;
    std::istream&amp; operator&gt;&gt; (
        std::istream&amp; in,
        matrix&lt;T,NR,NC,MM,L&gt;&amp; m
    );

    This function is defined inside the matrix_read_from_istream.h file.
    */</font>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>class</font> <b><a name='print_matrix_as_csv_helper'></a>print_matrix_as_csv_helper</b> 
    <b>{</b>
        <font color='#009900'>/*!
            This object is used to define an io manipulator for matrix expressions.
            In particular, this code allows you to write statements like:
                cout &lt;&lt; csv &lt;&lt; yourmatrix;
            and have it print the matrix with commas separating each element.
        !*/</font>
    <font color='#0000FF'>public</font>:
        <b><a name='print_matrix_as_csv_helper'></a>print_matrix_as_csv_helper</b> <font face='Lucida Console'>(</font>std::ostream<font color='#5555FF'>&amp;</font> out_<font face='Lucida Console'>)</font> : out<font face='Lucida Console'>(</font>out_<font face='Lucida Console'>)</font> <b>{</b><b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
        std::ostream<font color='#5555FF'>&amp;</font> <b><a name='operator'></a>operator</b><font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> m
        <font face='Lucida Console'>)</font> 
        <b>{</b>
            <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> r <font color='#5555FF'>=</font> <font color='#979000'>0</font>; r <font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>r<font face='Lucida Console'>)</font>
            <b>{</b>
                <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>long</u></font> c <font color='#5555FF'>=</font> <font color='#979000'>0</font>; c <font color='#5555FF'>&lt;</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <font color='#5555FF'>+</font><font color='#5555FF'>+</font>c<font face='Lucida Console'>)</font>
                <b>{</b>
                    <font color='#0000FF'>if</font> <font face='Lucida Console'>(</font>c<font color='#5555FF'>+</font><font color='#979000'>1</font> <font color='#5555FF'>=</font><font color='#5555FF'>=</font> m.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
                        out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>\n</font>";
                    <font color='#0000FF'>else</font>
                        out <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font color='#BB00BB'>m</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font> <font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> "<font color='#CC0000'>, </font>";
                <b>}</b>
            <b>}</b>
            <font color='#0000FF'>return</font> out;
        <b>}</b>

    <font color='#0000FF'>private</font>:
        std::ostream<font color='#5555FF'>&amp;</font> out;
    <b>}</b>;

    <font color='#0000FF'>class</font> <b><a name='print_matrix_as_csv'></a>print_matrix_as_csv</b> <b>{</b><b>}</b>;
    <font color='#0000FF'>const</font> print_matrix_as_csv csv <font color='#5555FF'>=</font> <b><a name='print_matrix_as_csv'></a>print_matrix_as_csv</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
    <font color='#0000FF'>inline</font> print_matrix_as_csv_helper <b><a name='operator'></a>operator</b><font color='#5555FF'>&lt;</font><font color='#5555FF'>&lt;</font> <font face='Lucida Console'>(</font>
        std::ostream<font color='#5555FF'>&amp;</font> out,
        <font color='#0000FF'>const</font> print_matrix_as_csv<font color='#5555FF'>&amp;</font> 
    <font face='Lucida Console'>)</font>
    <b>{</b>
        <font color='#0000FF'>return</font> <font color='#BB00BB'>print_matrix_as_csv_helper</font><font face='Lucida Console'>(</font>out<font face='Lucida Console'>)</font>;
    <b>}</b>

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font><font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='const_temp_matrix'></a>const_temp_matrix</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font>
        <font color='#0000FF'>typename</font> EXP
        <font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>struct</font> <b><a name='matrix_traits'></a>matrix_traits</b><font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>
    <b>{</b>
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> EXP::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> EXP::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> EXP::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> <font color='#979000'>1</font>;
    <b>}</b>;

    <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> EXP<font color='#5555FF'>&gt;</font>
    <font color='#0000FF'>class</font> <b><a name='const_temp_matrix'></a>const_temp_matrix</b> : <font color='#0000FF'>public</font> matrix_exp<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font> <font color='#5555FF'>&gt;</font>, noncopyable 
    <b>{</b>
    <font color='#0000FF'>public</font>:
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::type type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::const_ret_type const_ret_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::mem_manager_type mem_manager_type;
        <font color='#0000FF'>typedef</font> <font color='#0000FF'>typename</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::layout_type layout_type;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NR <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::NR;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> NC <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::NC;
        <font color='#0000FF'>const</font> <font color='#0000FF'>static</font> <font color='#0000FF'><u>long</u></font> cost <font color='#5555FF'>=</font> matrix_traits<font color='#5555FF'>&lt;</font>const_temp_matrix<font color='#5555FF'>&gt;</font>::cost;

        <b><a name='const_temp_matrix'></a>const_temp_matrix</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>EXP<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> :
            ref_<font face='Lucida Console'>(</font>item.ref<font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>
        <b><a name='const_temp_matrix'></a>const_temp_matrix</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> EXP<font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> :
            ref_<font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>
        <b>{</b><b>}</b>

        const_ret_type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font>
            <font color='#0000FF'><u>long</u></font> r, 
            <font color='#0000FF'><u>long</u></font> c
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>ref_</font><font face='Lucida Console'>(</font>r,c<font face='Lucida Console'>)</font>; <b>}</b>

        const_ret_type <b><a name='operator'></a>operator</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font> <font face='Lucida Console'>(</font> <font color='#0000FF'><u>long</u></font> i <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> 
        <b>{</b> <font color='#0000FF'>return</font> <font color='#BB00BB'>ref_</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='aliases'></a>aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> ref_.<font color='#BB00BB'>aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'>template</font> <font color='#5555FF'>&lt;</font><font color='#0000FF'>typename</font> U<font color='#5555FF'>&gt;</font>
        <font color='#0000FF'><u>bool</u></font> <b><a name='destructively_aliases'></a>destructively_aliases</b> <font face='Lucida Console'>(</font>
            <font color='#0000FF'>const</font> matrix_exp<font color='#5555FF'>&lt;</font>U<font color='#5555FF'>&gt;</font><font color='#5555FF'>&amp;</font> item
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> ref_.<font color='#BB00BB'>destructively_aliases</font><font face='Lucida Console'>(</font>item<font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nr'></a>nr</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> ref_.<font color='#BB00BB'>nr</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

        <font color='#0000FF'><u>long</u></font> <b><a name='nc'></a>nc</b> <font face='Lucida Console'>(</font>
        <font face='Lucida Console'>)</font> <font color='#0000FF'>const</font> <b>{</b> <font color='#0000FF'>return</font> ref_.<font color='#BB00BB'>nc</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>; <b>}</b>

    <font color='#0000FF'>private</font>:

        <font color='#0000FF'>typename</font> conditional_matrix_temp<font color='#5555FF'>&lt;</font><font color='#0000FF'>const</font> EXP, <font face='Lucida Console'>(</font>EXP::cost <font color='#5555FF'>&lt;</font><font color='#5555FF'>=</font> <font color='#979000'>1</font><font face='Lucida Console'>)</font><font color='#5555FF'>&gt;</font>::type ref_;
    <b>}</b>;

<font color='#009900'>// ----------------------------------------------------------------------------------------
</font>
    <font color='#0000FF'>typedef</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font>,<font color='#979000'>0</font>,<font color='#979000'>0</font>,default_memory_manager,column_major_layout<font color='#5555FF'>&gt;</font> matrix_colmajor;
    <font color='#0000FF'>typedef</font> matrix<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>float</u></font>,<font color='#979000'>0</font>,<font color='#979000'>0</font>,default_memory_manager,column_major_layout<font color='#5555FF'>&gt;</font> fmatrix_colmajor;

<b>}</b>

<font color='#0000FF'>#ifdef</font> _MSC_VER
<font color='#009900'>// restore warnings back to their previous settings
</font><font color='#0000FF'>#pragma</font> warning<font face='Lucida Console'>(</font>pop<font face='Lucida Console'>)</font>
<font color='#0000FF'>#endif</font>

<font color='#0000FF'>#endif</font> <font color='#009900'>// DLIB_MATRIx_
</font>

</pre></body></html>